﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace quanlynhasach
{
    public partial class frmReport : Form
    {
        public frmReport()
        {
            InitializeComponent();
            
        }

        private void frmReport_Load(object sender, EventArgs e)
        {
            this.Dock = DockStyle.Fill;
            dateTimePicker1.Value = DateTime.Now.Date;
            dateTimePicker2.Value = DateTime.Now.Date;
            dateTimePicker3.Value = DateTime.Now.Date;
            dateTimePicker4.Value = DateTime.Now.Date;
            Microsoft.Reporting.WinForms.ReportDataSource reportDataSource1 = new Microsoft.Reporting.WinForms.ReportDataSource();
            reportDataSource1.Name = "DataSet1";
            reportDataSource1.Value = this.NgaySource;
            reportViewer1.Reset();
            this.reportViewer1.LocalReport.DataSources.Add(reportDataSource1);
            this.reportViewer1.LocalReport.ReportEmbeddedResource = "quanlynhasach.Report.ReportBan.Reportngay.rdlc";
            hoaDonTableAdapter.Fill(trongngay.HoaDon, dateTimePicker1.Value);
            this.reportViewer1.RefreshReport();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked == true)
            {
                Microsoft.Reporting.WinForms.ReportDataSource reportDataSource1 = new Microsoft.Reporting.WinForms.ReportDataSource();
                reportDataSource1.Name = "DataSet1";
                reportDataSource1.Value = this.NgaySource;
                reportViewer1.Reset();
                this.reportViewer1.LocalReport.DataSources.Add(reportDataSource1);
                this.reportViewer1.LocalReport.ReportEmbeddedResource = "quanlynhasach.Report.ReportBan.Reportngay.rdlc";
                hoaDonTableAdapter.Fill(trongngay.HoaDon, dateTimePicker1.Value);
                this.reportViewer1.RefreshReport();
            }
            else
                if (radioButton2.Checked == true)
                {
                    Microsoft.Reporting.WinForms.ReportDataSource reportDataSource1 = new Microsoft.Reporting.WinForms.ReportDataSource();
                    reportDataSource1.Name = "DataSet1";
                    reportDataSource1.Value = this.ThangSource;
                    reportViewer1.Reset();
                    this.reportViewer1.LocalReport.DataSources.Add(reportDataSource1);
                    this.reportViewer1.LocalReport.ReportEmbeddedResource = "quanlynhasach.Report.ReportBan.Reportthang.rdlc";
                    hoaDonTableAdapter1.Fill(trongthang.HoaDon, dateTimePicker2.Value);
                    this.reportViewer1.RefreshReport();
                }
                else
                    if (radioButton3.Checked == true)
                    {
                        Microsoft.Reporting.WinForms.ReportDataSource reportDataSource1 = new Microsoft.Reporting.WinForms.ReportDataSource();
                        reportDataSource1.Name = "DataSet1";
                        reportDataSource1.Value = this.KhoangSource;
                        reportViewer1.Reset();
                        this.reportViewer1.LocalReport.DataSources.Add(reportDataSource1);
                        this.reportViewer1.LocalReport.ReportEmbeddedResource = "quanlynhasach.Report.ReportBan.Reportkhoang.rdlc";
                        hoaDonTableAdapter2.Fill(trongkhoang.HoaDon, dateTimePicker3.Value, dateTimePicker4.Value);
                        this.reportViewer1.RefreshReport();
                    }
        }

        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton1.Checked == true)
            {
                dateTimePicker1.Enabled = true;
                dateTimePicker2.Enabled = false;
                dateTimePicker3.Enabled = false;
                dateTimePicker4.Enabled = false;
            }
        }

        private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton2.Checked == true)
            {
                dateTimePicker1.Enabled = false;
                dateTimePicker2.Enabled = true;
                dateTimePicker3.Enabled = false;
                dateTimePicker4.Enabled = false;
            }
        }

        private void radioButton3_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton3.Checked == true)
            {
                dateTimePicker1.Enabled = false;
                dateTimePicker2.Enabled = false;
                dateTimePicker3.Enabled = true;
                dateTimePicker4.Enabled = true;
            }
        }
    }
}
